<?php
class Emails {
	var $messageContent;
		
	function sendEventRegistrationEmail($memberID,$eventID) {
		global $events;
		$member = new accountInfo();
		
		$subject = 'Event Registration: The Child Disability Connection';
		
		/*
		 * Get some event information
		 */
		$eventArray = $events->getEventDetails($eventID,'array');
		
		/*
		 * Get some member information
		 */
		$memberArray = $member->getMemberData($memberID);

		
		$message  = 'Hello '.$memberArray['FirstName'].','.Chr(10);
		$message .= 'This message is to confirm your registration for the following event:'.Chr(10).Chr(10);
		$message .= DBToMail($eventArray['EventName']).' : '.$eventArray['DateString'].Chr(10).Chr(10);
		$message .= DBToMail($eventArray['EventDescription']).Chr(10).Chr(10);
		$message .= '***** LOCATION *****'.Chr(10);
		$message .= DBToMail($eventArray['LocationString']).Chr(10).Chr(10);
		$message .= '***** FOR MORE INFORMATION *****'.Chr(10);
		$message .= 'See http://www.childdisabilityconnection.org/events.php?eventID='.$eventID.Chr(10);
		$message .= 'Or contact us at '.MASTER_MAIL;
		
		$mail = new Zend_Mail();
		$mail->setBodyText($message);
		$mail->setFrom(MASTER_MAIL, MASTER_MAIL_FROM);
		$mail->setSubject($subject);
		$mail->addTo($memberArray['Email1']);		
		$mail->send();	
	}
	
	function sendLibraryCheckoutEmail($memberID,$itemID,$status='success') {
		global $library;
		$member = new accountInfo();
		/*
		 * Get some member information
		 */
		$memberArray = $member->getMemberData($memberID);
		
		/*
		 * Get some library item information
		 */
		$libraryArray = $library->getLibraryItem($itemID,'array');	
		$subject = 'Library Checkout: The Child Disability Connection';
		
		$message  = 'Hello '.$memberArray['FirstName'].','.Chr(10);
		
		if ($status == 'success') {
			$message .= 'Thanks for registering with The Child Disability Connection. ';
			$message .= 'We hope you find our resources informative and helpful.'.Chr(10).Chr(10);
			$message .= 'To access your account in the future, simply go to The Child Disability Connection website and enter your email address in the Parent Login box at the top of each page.'.Chr(10).Chr(10);
		} elseif ($status == 'out') {
			
		}
		
		$message .= '***** FOR MORE INFORMATION *****'.Chr(10);
		$message .= 'See http://www.childdisabilityconnection.org';
		$message .= 'Or contact us at '.MASTER_MAIL;
		
		$mail = new Zend_Mail();
		$mail->setBodyText($message);
		$mail->setFrom(MASTER_MAIL, MASTER_MAIL_FROM);
		$mail->setSubject($subject);
		$mail->addTo($memberArray['Email1']);		
		$mail->send();	
	}
	
	function sendNewAccountEmail($memberID) {
		$member = new accountInfo();
		/*
		 * Get some member information
		 */
		$memberArray = $member->getMemberData($memberID);
		$subject = 'Welcome to The Child Disability Connection';
		
		$message  = 'Hello '.$memberArray['FirstName'].','.Chr(10);
		$message .= 'Thanks for registering with The Child Disability Connection. ';
		$message .= 'We hope you find our resources informative and helpful.'.Chr(10).Chr(10);
		$message .= 'To access your account in the future, simply go to The Child Disability Connection website and enter your email address in the Parent Login box at the top of each page.'.Chr(10).Chr(10);
		$message .= '***** FOR MORE INFORMATION *****'.Chr(10);
		$message .= 'See http://www.childdisabilityconnection.org';
		$message .= 'Or contact us at '.MASTER_MAIL;
		
		$mail = new Zend_Mail();
		$mail->setBodyText($message);
		$mail->setFrom(MASTER_MAIL, MASTER_MAIL_FROM);
		$mail->setSubject($subject);
		$mail->addTo($memberArray['Email1']);		
		$mail->send();	
	}
	
	function sendContactFormEmail() {
		/*
		 * Check for required
		 */
		if (empty($_POST['subject']) || $_POST['subject'] == 'select') {
			$subject = 'Website contact.';
		} else {
			$subject = stripslashes($_POST['subject']);
		}
		if (empty($_POST['email'])) {
			$from = 'noreply@childdisabilityconnection.org';
		} else {
			$from = $_POST['email'];
		}
		
		$message  = $_POST['name'].' has submitted a contact form on '.date('m/d/Y').Chr(10);
		$message .= '--------------------------------------------------------'.Chr(10).stripslashes($_POST['message']);
		 	
		$mail = new Zend_Mail();
		$mail->setBodyText($message);
		$mail->setFrom($from);
		$mail->setSubject($subject);
		$mail->addTo(MASTER_MAIL);		
		if ($mail->send()) {
			return 1;	
		} else {
			return 0;
		}
	}
}
?>